const path = require('path');
const { IgnorePlugin } = require('webpack');
const { VantResolver } = require('unplugin-vue-components/resolvers');
const ComponentsPlugin = require('unplugin-vue-components/webpack');
function resolve(dir) {
  return path.join(__dirname, dir);
}
module.exports = {
  pages: {
    app: {
      // page 的入口
      entry: 'src/main.ts',
      filename: 'index.html',
    },
  },
  publicPath: process.env.VUE_APP_PUBLIC_PATH,
  configureWebpack: {
    plugins: [
      new IgnorePlugin({
        contextRegExp: /moment$/,
      }),
      ComponentsPlugin({
        resolvers: [VantResolver()],
      }),
    ],
  },
  chainWebpack: config => {

    config.resolve.alias.set('@', resolve('./src'));
    config.resolve.alias.set('vue$', resolve('./node_modules/vue/dist/vue.esm-bundler.js'));
    // 打包上线后去除掉代码中所有的console.log
    config.optimization.minimizer('terser').tap((args) => {
      args[0].terserOptions.compress.drop_console = true
      return args
    })
  },
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          modifyVars: {
          },
          javascriptEnabled: true,
        },
      },
    },
  },
  productionSourceMap: false,
  lintOnSave: 'warning',
  transpileDependencies: [],

  devServer: {
    headers: {
      'Access-Control-Allow-Origin': '*'
    },
    proxy: {
      /*'/indicator': {
        target: 'http://172.20.0.25:30624/indicator/',
        secure:false,
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/model': ''
        }
      },*/
      '/model': {
        target: 'http://model-sys-project.mes.bgechina.cn/model/v2',
        secure:false,
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/model': ''
        }
      }
    }
  }
};
